<?php

namespace App\Services\DataCache;

use App\Models\AdMediaDocking;
use App\Services\ServiceBase;

class AdMediaDockingDataCache extends ServiceBase
{
    protected $dockingList;

    public function __construct()
    {
        parent::__construct();
        $msg = file_get_contents(storage_path("datacache/docking.dat"));
        $this->dockingList = json_decode($msg, true);
    }

    public function get($id)
    {
        if (!isset($this->dockingList[$id])) {
            $data = AdMediaDocking::find($id);
            return $data->toArray();
        } else {
            return $this->dockingList[$id];
        }
    }
}
